#include "moto_control.h"



/* name:group1_moto_set()
 *  function:set GROUP1 moto pwm duty.
 *  input:
 *        channel:GROUP1_CHANNEL1 / GROUP1_CHANNEL2
 *        duty: from 1~999(i set three status[fast(999) middle(500) slow(300)])
 *  output:none
 *  time:2025-03-12
 */
void group1_moto_set(uint16_t channel, uint16_t duty)
{
    switch (channel)
    {
    case GROUP1_CHANNEL1:
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP1_MOTO_CHANNEL1, duty);break;
    case GROUP1_CHANNEL2:
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP1_MOTO_CHANNEL2, duty);break;
    case GROUP1_ALL:
    {
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP1_MOTO_CHANNEL1, duty);
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP1_MOTO_CHANNEL2, duty);
    }break;
    }
}

/* name:group2_moto_set()
 *  function:set GROUP2 moto pwm duty.
 *  input:
 *        channel:GROUP2_CHANNEL1 / GROUP2_CHANNEL2
 *        duty: from 1~999(i set three status[fast(999) middle(500) slow(300)])
 *  output:none
 *  time:2025-03-12
 */
void group2_moto_set(uint16_t channel, uint16_t duty)
{
    switch (channel)
    {
    case GROUP2_CHANNEL1:
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP2_MOTO_CHANNEL1, duty);break;
    case GROUP2_CHANNEL2:
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP2_MOTO_CHANNEL2, duty);break;
    case GROUP2_ALL:
    {
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP2_MOTO_CHANNEL1, duty);
        timer_channel_output_pulse_value_config(GROUP_MOTO, GROUP2_MOTO_CHANNEL2, duty);
    }break;
    }
}

/* name:forward_set()
 *  function:set forward status pwm duty.
 *  input:none
 *  output:none
 *  time:2025-03-12
 */
void forward_set(uint16_t duty)
{
    group2_moto_set(GROUP2_CHANNEL2, duty);
}

/* name:recoil_set()
 *  function:set recoil status pwm duty.
 *  input:none
 *  output:none
 *  time:2025-03-12
 */
void recoil_set(uint16_t duty)
{
    group1_moto_set(GROUP1_CHANNEL1, duty);
}

/* name:turn_left_set()
 *  function:set turn left status pwm duty.
 *  input:none
 *  output:none
 *  time:2025-03-12
 */
void turn_left_set(uint16_t duty)
{
    group2_moto_set(GROUP2_CHANNEL1, duty);
}

/* name:turn_right_set()
 *  function:set turn right status pwm duty.
 *  input:none
 *  output:none
 *  time:2025-03-12
 */
void turn_right_set(uint16_t duty)
{
    group1_moto_set(GROUP1_CHANNEL2, duty);
}

/* name:stop_set()
 *  function:stop all channel output.
 *  input:none
 *  output:none
 *  time:2025-03-12
 */
void stop_set()
{
    group1_moto_set(GROUP1_ALL, 0);
    group2_moto_set(GROUP2_ALL, 0);
}


